<template>
	<view class="page">
		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed :bottomShadow="false" backTitle=" ">
		  <view class="" >
			<text class="tn-text-lg">系统消息列表</text>
		  </view>
		</tn-nav-bar>
		
		<view>
			
			<scroll-view  @scrolltolower="loadMore"  :style="'height:' + windowHeight+''"  scroll-y="true">
			 
			   <view class="tn-margin-bottom-lg" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
			     <block v-for="(item, index) in messageList" :key="index">
			       <view class="article-shadow tn-margin">
			         <view class="tn-flex">
			           <view class="tn-margin-sm tn-padding-top-xs" style="width: 100%;">
			             <view class="tn-text-md  clamp-text-1 tn-text-justify">
			               {{ item.content }}
			             </view>
			             <view class="tn-flex tn-flex-row-between tn-flex-col-between tn-padding-top-xs" style="min-height: 105rpx;">
			               <text class="tn-text-df tn-color-gray clamp-text-2 tn-text-justify">
								{{ item.createTime }}
			               </text>
			             </view>
			           </view>
			         </view>
			       </view>
			     </block>
			   </view>
			   <view class='tn-tabbar-height'></view>
			</scroll-view>
				  
		</view>
	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	import request from "@/common/request.js"
	export default {
		mixins: [template_page_mixin],
		data() {
			return {
				messageList : [],
				pageSize:10,
				pageNum:1,
				total:0,
			}
		},
		onLoad(){
			this.loadData()
			this.readAll()
		},
		methods: {
			loadMore(){
				if(this.total >= this.messageList.length()){
					// 没有更多消息
					uni.showToast({
						icon: "none",
						title: '没有更多消息',
						duration: 2000
					});
				}else{
					this.loadData()
				}
			},
			loadData(){
				request.get("friend/wx/notice/notice",{pageNum:this.pageNum, pageSize:this.pageSize}).then(res=>{
				  let _data = res[1]['data']
				  if(_data.code == 200){
					  this.messageList = [...this.messageList, ..._data.rows];
					  this.total = _data.total
				  }
				});
			},
			readAll(){
				request.get("friend/wx/notice/readNotice")
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
